const mongoose = require('mongoose');

const MONGO_URL = 'mongodb://localhost:27017/lowcode';

mongoose.connect(MONGO_URL, {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

const db = mongoose.connection;
db.on('error', console.error.bind(console, 'MongoDB connection error:'));
db.once('open', () => {
  const { host, port, name } = db;
     console.log(`Connected to MongoDB at ${host}:${port}/${name}`);
});

module.exports = mongoose; 